<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* 每次刷新 */
    [v-cloak] {
      display: none;
    }
  </style>
</head>

<body>

  <div id="app">
    <!-- @input 这个事件针对有输入框的才有 -->
    <input @input="getValue" v-model.number="inpValue">
    <input @input="getValue" v-model.lazy="inpValue">
    <input @input="getValue" v-model.trim="inpValue">
    <!-- v-model  双向绑定 一般用于input select textarea -->
    <!-- .lazy - 取代 input 监听 change 事件
    .number - 输入字符串转为有效的数字
    .trim - 输入首尾空格过滤 -->
    <h1 v-cloak>{{h1Txt}}</h1>


    <input type="checkbox" name="hobby" value=1 v-model="hobbyArr">1
    <input type="checkbox" name="hobby" value=2 v-model="hobbyArr">2
    <input type="checkbox" name="hobby" value=3 v-model="hobbyArr">3
    <h2>{{hobbyArr}}</h2>


  </div>


  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  <script>
    new Vue({
      el: "#app",
      data: {
        h1Txt: "",
        inpValue: "",
        hobbyArr: [],
      },
      methods: {
        getValue() {
          this.h1Txt = event.target.value
          // console.log(event.target.value);//获取输入的值
          // console.log(event.data);
        }
      }

    })
  </script>

</body>

</html>